using BLL;
using DAL;
using Microsoft.EntityFrameworkCore;

namespace _11._4WebApI
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // Add services to the container.

            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();
            builder.Services.AddDbContext<MyContext>(x =>
            {
                x.UseSqlServer(builder.Configuration.GetConnectionString("Conn"));
            });
            builder.Services.AddScoped<RoomHaoDAL>();
            builder.Services.AddScoped<RoomTypeDAL>();
            builder.Services.AddScoped<RoomHaoBLL>();
            builder.Services.AddScoped<RoomTypeBLL>();
            var app = builder.Build();
            app.UseCors(x=>x.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseAuthorization();
            app.UseFileServer();

            app.MapControllers();

            app.Run();
        }
    }
}
